home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_12
/
1012018d
< prev
next >
Wrap
Text File
|
1992-10-05
|
497b
|
25 lines
/* strtok function */
#include <string.h>
char *(strtok)(char *s1, const char *s2)
{ /* find next token in s1[] delimited by s2[] */
char *sbegin, *send;
static char *ssave = ""; /* for safety */
sbegin = s1 ? s1 : ssave;
sbegin += strspn(sbegin, s2);
if (*sbegin == '\0')
{ /* end of scan */
ssave = ""; /* for safety */
return (NULL);
}
send = sbegin + strcspn(sbegin, s2);
if (*send != '\0')
*send++ = '\0';
ssave = send;
return (sbegin);
}